import java.util.Scanner;

class NameException extends RuntimeException{
    public NameException(String message) {
        super(message);
    }

    public NameException() {
        super();
    }
}

class PasswordException extends RuntimeException{
    public PasswordException() {
        super();
    }

    public PasswordException(String message) {
        super(message);
    }
}
public class LogIn {
    public String name = "zhangsan";
    public String password = "123456";
    public void login(String name, String password)throws NameException,PasswordException{
        if(!this.name.equals(name)){
            throw new NameException("用户名错误！");
        }
        if(!this.password.equals(password)){
            throw new PasswordException("密码错误！");
        }
        System.out.println("登陆成功！");
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name = scanner.nextLine();
        System.out.println("请输入密码：");
        String password = scanner.nextLine();
        LogIn logIn = new LogIn();
        try {
            logIn.login(name, password);
        } catch (NameException e) {
            e.printStackTrace();
        } catch (PasswordException e) {
            e.printStackTrace();
        }
    }
}
